maintainer="Hoang Nguyen <folliekazetani@protonmail.com>"
pkgname=pulumi-language-yaml
pkgver=1.11.1
pkgrel=0
pkgdesc="Infrastructure as Code SDK (YAML language provider)"
url="https://pulumi.com/"
# blocked by pulumi
arch="x86_64 aarch64"
license="Apache-2.0"
makedepends="go"
checkdepends="pulumi pulumi-language-go"
source="$pkgname-$pkgver.tar.gz::https://github.com/pulumi/pulumi-yaml/archive/refs/tags/v$pkgver.tar.gz"
builddir="$srcdir/pulumi-yaml-$pkgver"
options="net" # download Go modules

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	mkdir -p bin
	go build -v \
		-ldflags "-X github.com/pulumi/pulumi-yaml/pkg/version.Version=v$pkgver" \
		-o bin/ \
		./cmd/...
}

check() {
	# expose pulumi-language-yaml binary in PATH for the tests to use
	export PATH="$PATH:$builddir/bin"

	# Unset -trimpath, since some tests create run_plugin_version_test.go file using relative path.
	# Skipped tests depend on cue-cli, and externally downloaded schema files (scripts/get_schemas.sh is broken upstream).
	GOFLAGS="${GOFLAGS/-trimpath/}" PULUMI_SKIP_UPDATE_CHECK=true \
		go test -skip 'Test(GenerateProgram|ImportTemplate|GenerateExamples|Parameterized|ResourceOrderingWithDefaultProvider)' ./...
}

package() {
	install -Dm755 bin/pulumi-language-yaml bin/pulumi-converter-yaml -t "$pkgdir"/usr/bin/
}

sha512sums="
551501dea2f67102d571273ea47b7e90239c703e1af2179e614cfae5bff6e8910432e60a932c0ab781c265f2a989cf2bb18b99ffa7b72dfa17e24dfae5866d20  pulumi-language-yaml-1.11.1.tar.gz
"
